<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎您登录</title>
    <style type="text/css">
        html, body {
            height: 100%;
            padding: 0;
            margin: 0;
        }

        * {
            box-sizing: border-box;
        }

        body {
            background: url("__PUBLIC__/Admin/images/bg.jpg") no-repeat;
            background-size: cover;
            background-attachment:fixed;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        #login {
            width: 350px;
            height: 480px;
        }
        #title {
            text-align: center;
            color: white;
            font-size: 2em;
            margin-bottom: 40px;
        }
        .row {
            width: 100%;
            height: 60px;
            display: flex;
            justify-content: stretch;
            border-bottom: 1px solid #767b87;
            align-items: center;
        }

        .row > input {
            height: 60px;
            line-height: 60px;
            font-size: 1.2em;
            outline: none;
            border: none;
            background-color: rgba(0, 0, 0, 0);
            flex-grow: 1;
            text-indent: 20px;
            color: #767b87;
        }
        ::-webkit-input-placeholder {
            color: #767b87;
        }
        :-moz-placeholder {
            color: #767b87;
        }
        ::-moz-placeholder {
            color: #767b87;
        }
        :-ms-input-placeholder {
            color: #767b87;
        }
        .row img {
            width: 20px;
            height: 20px;
        }

        #recaptcha {
            color: #767b87;
            font-size: .9em;
            margin-right: 20px;
            cursor: pointer;
        }
        #captcha {
            margin-top: 16px;
        }
        #recaptcha {
            position: absolute;
            right: 8px;
        }
        #submit {
            width: 350px;
            border-radius: 30px;
            color: white;
            background-color: #28a7e1;
            border: none;
            font-size: 1.2em;
            padding: 16px 0;
            margin-top: 60px;
            outline: none;
        }
        input:-webkit-autofill,
        input:-webkit-autofill:hover,
        input:-webkit-autofill:focus,
        input:-webkit-autofill:active {
            -webkit-transition-delay: 99999s;
            -webkit-transition: color 99999s ease-out, background-color 99999s ease-out;
        }
    </style>
</head>
<body>
    <div id="login">
        <div id="title">达美康管理平台</div>
        <div>
            <form action="{:U('login')}" id="form">
                <div class="row">
                    <img src="__PUBLIC__/Admin/images/user.png">
                    <input type="text" placeholder="请填写用户名" id="username" name="username">
                </div>
                <div class="row">
                    <img src="__PUBLIC__/Admin/images/lock.png">
                    <input type="password" placeholder="请填写密码" id="password" name="password">
                </div>
                <div class="row" style="position: relative">
                    <img src="__PUBLIC__/Admin/images/captcha.png">
                    <input  type="text" placeholder="请填写验证码" id="verify" name="verify">
                    <span id="recaptcha">换一张?</span>
                </div>
                <img id="captcha" src="{:U('Public/verify')}">
                <div>
                    <button id="submit" type="button">登录</button>
                </div>
            </form>

        </div>
    </div>

    <!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/jquery-1.10.2.min.js"></script>
    <![endif]-->
    <!--[if gte IE 9]><!-->
    <script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
    <!--<![endif]-->
    <script type="text/javascript">
        $('#recaptcha, #captcha').click(function () {
            var url = "{:U('Public/verify')}";
            var hash_qmark = url.indexOf('?') !== -1;
            url += (hash_qmark ? '&' : '?') + '_=' + Math.random();
            $("#captcha").attr('src', url);
        })

        $('#submit').click(function () {
            if (!$('#username').val().trim() || !$('#password').val().trim() || !$('#verify').val().trim()) {
                alert('请填写完整');
            } else {
                var self = $('#form');
                $.post(self.attr("action"), self.serialize(), success, "json");
                return false;

                function success(data){
                    if(data.status){
                        window.location.href = data.url;
                    } else {
                        alert(data.info);
                        $("#captcha").click();
                    }
                }
            }
        });

        $('input').keyup(function (e) {
            if (e.which === 13){
                $('#submit').click();
            }
        })
    </script>
</body>
</html>